<%@page import="com.tiantian.domain.Bindingplatformaccounts"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE>
<html>
<head>
<style type="text/css">
.update {
	font-size: 12px;
	padding-left: 15px;
	color: #0033FF;
}
</style>
<script src="<c:url value='/static/jquery/jquery-1.9.1.min.js'/>"
	type="text/javascript"></script>
<script type="text/javascript"
	src="<c:url value='/static/common/uc_message.js'/>"></script>
<link rel="stylesheet"
	href="<c:url value='/static/themes/bootstrap/bootstrapValidator.min.css'/>" />
<script type="text/javascript"
	src="<c:url value='/static/themes/bootstrap/bootstrapValidator.min.js'/>"></script>
<link rel="stylesheet"
	href="<c:url value='/static/themes/lightbox2-master/css/lightbox.min.css'/>" />
<title>买手用户详情</title>
</head>
<body>
	<div class="col-lg-12">
		<div id="message"></div>
		<div class="panel panel-default bk-bg-white">
			<div class="panel-heading bk-bg-white">
				<h4>
					账户信息 <span style="font-size: 14px; padding-left: 30px">状态&nbsp;：
						<input type="hidden" name="accountStatus" id="accountStatus"
						value="${user.accountStatus}" /> <c:choose>
							<c:when test="${user.accountStatus==0}">
								<span style="color: #FFB253;">使用中</span>
								<span href="#" class="update buyer_state"
									accountStatus="${user.accountStatus}"
									buyersUserId="${user.buyersUserId}">冻结</span>
							</c:when>
							<c:otherwise>
								<span style="color: #FFB253;">已冻结</span>
								<span href="#" class="update buyer_state"
									accountStatus="${user.accountStatus}"
									buyersUserId="${user.buyersUserId}">使用</span>
							</c:otherwise>
						</c:choose>
					</span>
				</h4>
			</div>
			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form class="form-horizontal" id="userForm">
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">生财ID&nbsp;：</label>
									<div class="col-sm-7" style="padding-top: 10px;">${user.buyersUserId}</div>
									<input type="hidden" id="buyersUserId"
										value="${user.buyersUserId }">
								</div>

								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">注册时间&nbsp;：</label>
									<div class="col-sm-7" style="padding-top: 10px;">
										<fmt:formatDate value="${user.registrationTime}"
											pattern="yyyy-MM-dd HH:mm:ss" />
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">姓名&nbsp;：</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="fullName"
											name="fullName" value="${user.fullName }" placeholder="姓名">
									</div>
								</div>


							</div>
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">登录账号&nbsp;：</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="userName"
											name="userName" value="${user.userName }" placeholder="登录账号">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码&nbsp;：</label>
									<div class="col-sm-7">
										<input type="password" class="form-control" id="loginPassword"
											name="loginPassword" value="notchange" placeholder="密码">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">联&nbsp;系&nbsp;电&nbsp;话&nbsp;：</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="phone"
											name="phone" value="${user.phone }" placeholder="联系电话">
									</div>
								</div>



							</div>
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">Q&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Q&nbsp;：</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="qqno" name="qqno"
											value="${user.qqno }" placeholder="QQ">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">微&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;信&nbsp;：</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="wechatNo"
											name="wechatNo" value="${user.wechatNo }" placeholder="微信">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别&nbsp;：</label>
									<div class="col-sm-7 " style="padding-top: 10px;">
										<input type="radio" ${user.sex=='0'?'checked':'' } value="0"
											name="sex" id="sex_0" /> 女
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="radio"
											${user.sex=='1'?'checked':'' } value="1" name="sex"
											id="sex_1" /> 男
									</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">昵&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称&nbsp;：</label>
									<div class="col-sm-7">
										<input type="text" class="form-control" id="nickName"
											name="nickName" value="${user.nickName }" placeholder="昵称">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">身份证号码：</label>
									<div class="col-sm-7 ">
										<input type="text" class="form-control" id="idcard"
											name="idcard" value="${user.idcard }">
									</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">头&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;像&nbsp;：</label>
									<div class="col-sm-7">
										<c:if
											test="${user.headPortrait!=null&&user.headPortrait!='' }">
											<a class="example-image-link"
													href="${pic_root }${user.headPortrait }"
													data-title="头像" data-lightbox="example-1"><img
													class="example-image"
													src="${pic_root }${user.headPortrait }" height="60"
													width="60" alt="" /></a> 
										</c:if>
										<input type="hidden" class="form-control" id="headPortrait"
											name="headPortrait" value="${pic_root }${user.headPortrait }"
											placeholder="头像">
									</div>
								</div>
								<div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">身份证正面图片：</label>
									<div class="col-sm-7">
										<c:if
											test="${user.idcardphoto1!=null&&user.idcardphoto1!='' }">
											<a class="example-image-link"
													href="${pic_root }${user.idcardphoto1 }"
													data-title="身份证正面图片" data-lightbox="example-1"><img
													class="example-image"
													src="${pic_root }${user.idcardphoto1 }" height="60"
													width="60" alt="" /></a> 
										</c:if>

										<input type="hidden" class="form-control" id="idcardphoto1"
											name="idcardphoto1" value="${pic_root }${user.idcardphoto1 }">
									</div>
								</div>
								<%-- <div class="form-group col-sm-4">
									<label class="col-sm-5 control-label">身份证反面图片:</label>
									<div class="col-sm-7">
										<c:if
											test="${user.idcardphoto2!=null&&user.idcardphoto2!='' }">
											
											<a class="example-image-link"
													href="${pic_root }${user.idcardphoto2 }"
													data-title="身份证反面图片" data-lightbox="example-1"><img
													class="example-image"
													src="${pic_root }${user.idcardphoto2 }" height="60"
													width="60" alt="" /></a> 
										</c:if>

										<input type="hidden" class="form-control" id="idcardphoto2"
											name="idcardphoto2" value="${user.idcardphoto2 }">
									</div>
								</div> --%>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

		<div id="bank_message"></div>
		<div class="panel panel-default bk-bg-white">
			<div class="panel-heading bk-bg-white">
				<h4>银行卡信息</h4>
			</div>

			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form class="form-horizontal">
							<c:forEach items="${bankList }" var="bank" varStatus="status">
								<div class="row">
									<h4>
										绑定银行${status.index+1}<span
											style="font-size: 14px; padding-left: 25px">状态&nbsp;：
											<span style="color: #FFB253;">已绑定</span> <span
											class="update bank_state"
											buyersUserId="${bank.buyersuserid }"
											bankcardid="${bank.bankcardid}">删除</span>

										</span>
									</h4>
								</div>
								<div class="row">
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">银行名称&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">${bank.bname}</div>
									</div>

									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">开户姓名&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											${bank.cardholdername }</div>
									</div>

									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">${bank.bankcardaccount }</div>
									</div>

								</div>
								<div class="row">
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">所在城市&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">${bank.areaname}</div>
									</div>
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">开&nbsp;户&nbsp;行&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">${bank.aname==null?bank.bname:bank.aname }</div>
									</div>
								</div>
							</c:forEach>
						</form>
					</div>
				</div>

			</div>
		</div>
		<div id="account_message"></div>
		<div class="panel panel-default bk-bg-white">
			<div class="panel-heading bk-bg-white">
				<h4>账号绑定信息</h4>
			</div>

			<div class="panel-body">
				<div class="form-group col-sm-12">
					<div class="col-sm-12">
						<form class="form-horizontal">
							<c:forEach items="${bindAccounts }" var="account"
								varStatus="status">
								<div class="row">
									<h4>
										<c:set value="${account.approvalstatus}" var="accountStatus" />

										<c:set
											value='<%=pageContext.getAttribute("accountStatus") + ""%>'
											var="accountStatus" />
										绑定账号${status.index+1}<span
											style="font-size: 14px; padding-left: 25px">状态&nbsp;：
											<span style="color: #FFB253;">
												${accountStatus=='1'?"已绑定":"已解绑"} </span> <span
											class="update account_state"
											status="${account.approvalstatus}"
											platformAccountId="${account.platformaccountid}">
												${accountStatus=='1'?"解绑":"绑定"} </span>
										</span>
									</h4>
								</div>
								<div class="row">
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">平台类型&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">${account.platformname}</div>
									</div>

									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">平台等级&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											${account.creditrating }
										</div>
									</div>

									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">账号名称&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">${account.platformaccount }</div>
									</div>

								</div>
								<div class="row">
									<c:if test="${account.platformid=='1'}">
										<div class="form-group col-sm-4">
											<label class="col-sm-5 control-label">是否花呗&nbsp;：</label>
											<div class="col-sm-7" style="padding-top: 10px;">
												${account.ifhuabei=='0'?'否':'是'}</div>
										</div>
									</c:if>
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">收&nbsp;货&nbsp;人&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">${account.receiver }</div>
									</div>
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">收货人手机号：</label>
										<div class="col-sm-7" style="padding-top: 10px;">${account.receiverphone }</div>
									</div>
								</div>
								<div class="row">
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">详细地址：</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											${addresses[status.index] }
										</div>
									</div>
								</div>
								<div class="row">
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">信誉等级&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											<div class="col-sm-7">
												<select   class="form-control changeCreditRating" >
													<c:forEach items="${creditRating }" var="c">
														<c:if test="${c.platformid==account.platformid }">
															<option ${c.creditratingno==account.creditratingno?'selected':'' } 
															value="${account.platformaccountid}_${c.creditratingno }">
																${c.creditrating }
															</option>									
														</c:if>
													</c:forEach>
													
												</select>
											</div>
											<c:if
												test="${account.creditratingpic!=null&&account.creditratingpic!=''}">
												<a class="example-image-link"
													href="${pic_root }${account.creditratingpic}"
													data-title="信誉等级" data-lightbox="example-1"><img
													class="example-image"
													src="${pic_root }${account.creditratingpic}" height="50"
													width="50" alt="" /></a>
											</c:if>
										</div>
									</div>
									<%-- <div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">身份证正面照&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											<c:if
												test="${account.taobaopic1!=null&&account.taobaopic1!=''}">
												<a class="example-image-link"
													href="${pic_root }${account.taobaopic1}"
													data-title="身份证正面照" data-lightbox="example-1"><img
													class="example-image"
													src="${pic_root }${account.taobaopic1}" height="60"
													width="60" alt="" /></a> 
											</c:if>
										</div>
									</div>
									<div class="form-group col-sm-4">
										<label class="col-sm-5 control-label">身份证背面照&nbsp;：</label>
										<div class="col-sm-7" style="padding-top: 10px;">
											<c:if
												test="${account.taobaopic2!=null&&account.taobaopic2!=''}">

												<a class="example-image-link"
													href="${pic_root }${account.taobaopic2}"
													data-title="身份证背面照" data-lightbox="example-1"><img
													class="example-image"
													src="${pic_root }${account.taobaopic2}" height="60"
													width="60" alt="" /></a>
											</c:if>

										</div>
									</div> --%>
								</div>
							</c:forEach>
						</form>
					</div>
				</div>

			</div>
		</div>
		<div>
			<div class="form-group " style="text-align: center;">
				<button type="button" id="save" class="btn btn-warning btn-sm"
					style="width: 150px">保存</button>
				<button type="button" id="unsave" class="btn btn-default btn-sm"
					style="width: 150px">取消</button>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$(function($) {
			$('#userForm')
					.bootstrapValidator(
							{
								message : '这个值未通过验证',
								feedbackIcons : {
									valid : 'glyphicon glyphicon-ok',
									invalid : 'glyphicon glyphicon-remove',
									validating : 'glyphicon glyphicon-refresh'
								},
								submitHandler : function(validator, form,
										submitButton) {
									alert(validator);
								},
								fields : {
									userName : {
										validators : {
											notEmpty : {
												message : '登录账号是必须的不能为空'
											},
											stringLength : {
												min : 1,
												max : 15,
												message : '登录账号长度在1-15位'
											},
											regexp : {
												regexp : /^[0-9]+$/,
												message : '登录名只能为数字'
											},
										}
									},
									loginPassword : {
										validators : {
											notEmpty : {
												message : '密码是必须的不能为空'
											},
											stringLength : {
												min : 8,
												max : 20,
												message : '登录账号长度在8-20位'
											}
										}
									},
									phone : {
										validators : {
											stringLength : {
												min : 1,
												max : 15,
												message : '联系电话长度在1-15位'
											},
											regexp : {
												regexp : /^[0-9]+$/,
												message : '联系电话只能为数字'
											},
										}
									},
									qqno : {
										validators : {
											stringLength : {
												min : 1,
												max : 20,
												message : 'QQ长度在1-20位'
											}
										}
									},
									wechatNo : {
										validators : {
											stringLength : {
												min : 1,
												max : 20,
												message : '微信长度在1-20位'
											}
										}
									},
									nickName : {
										validators : {
											stringLength : {
												min : 1,
												max : 20,
												message : '昵称长度在1-20位'
											}
										}
									},
									fullName : {
										validators : {
											stringLength : {
												min : 1,
												max : 20,
												message : '姓名长度在1-20位'
											}
										}
									},
									idcard : {
										validators : {
											stringLength : {
												min : 1,
												max : 20,
												message : '身份证长度在1-20位'
											},
											regexp : {
												regexp : /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/,
												message : '身份证有误'
											},
										}
									}

								}
							}).on('success.form.bv', function(e) {

						var buyersUserID = $('#buyersUserId').val();
						var userName = $('#userName').val();
						var phone = $('#phone').val();
						var qqNo = $('#qqno').val();
						var wechatNo = $('#wechatNo').val();
						var fullName = $('#fullName').val();
						var loginPassword = $('#loginPassword').val();
						var sex = $("input[name='sex']:checked").val();
						var nickName = $('#nickName').val();
						var idCard = $('#idCard').val();
						var headPortrait = $("#headPortrait").val();
						var idcardphoto1 = $('#idcardphoto1').val();
						var idcardphoto2 = $('#idcardphoto2').val();
						$.ajax({
							type : "post",
							url : path + "/user/updateBuyersUser",
							cache : false,
							data : {
								buyersUserID : buyersUserID,
								userName : userName,
								loginPassword : loginPassword,
								accountStatus : $('#accountStatus').val(),
								phone : phone,
								qqNo : qqNo,
								wechatNo : wechatNo,
								fullName : fullName,
								sex : sex,
								nickName : nickName,
								idCard : idCard,
								headPortrait : headPortrait,
								idcardphoto1 : idcardphoto1,
								idcardphoto2 : idcardphoto2,
								_t : new Date().getTime()
							},
							dataType : "json",
							success : function(data) {
								showmessage(data.msg, function() {
									if (data.success) {
										location.reload(true);
									}
								});

							}
						});
					});

			//保存
			$('#save').click(function() {

				$('#userForm').bootstrapValidator('validate');

			});
			//取消
			$('#unsave').click(function() {
				window.location.href = path + "/user/buyersUsersList";
			});
			$(".changeCreditRating").on("change",function(){
				var val=this.value;
				$.ajax({
					type : "post",
					url : path + "/user/updateBindingPlatformAccounts",
					cache : false,
					data : {
						platformAccountId :val.split("_")[0],
						creditRatingNo : val.split("_")[1],
						_t : new Date().getTime()
					},
					dataType : "json",
					success : function(data) {
						showmessage(data.msg, function() {
							if (data.success) {
								location.reload(true);
							}
						});

					}
				});
				
			})
			//买手账号冻结/使用
			$('.buyer_state').click(function() {
				var _this = this;
				$.ajax({
					type : "post",
					url : path + "/user/editBuyerStatus",
					cache : false,
					data : {
						id : $(_this).attr('buyersUserId'),
						accountStatus : $(_this).attr('accountStatus'),
						_t : new Date().getTime()
					},
					dataType : "json",
					success : function(data) {
						showmessage(data.msg, function() {
							if (data.success) {
								location.reload(true);
							}
						});

					}
				});
			});

			//银行卡删除
			$('.bank_state').click(function() {
				var _this = this;
				$.ajax({
					type : "post",
					url : path + "/user/deleteBuyersBankCard",
					cache : false,
					data : {
						buyersUserId : $(_this).attr('buyersUserId'),
						bankcardid : $(_this).attr('bankcardid'),
						_t : new Date().getTime()
					},
					dataType : "json",
					success : function(data) {
						showmessage(data.msg, function() {
							if (data.success) {
								location.reload(true);
							}
						}, 'bank_message');

					}
				});
			});

			//账号状态
			$('.account_state').click(function() {
				var _this = this;
				$.ajax({
					type : "post",
					url : path + "/user/editBindingPlatformAccounts",
					cache : false,
					data : {
						platformAccountId : $(_this).attr('platformAccountId'),
						status : $(_this).attr('status'),
						_t : new Date().getTime()
					},
					dataType : "json",
					success : function(data) {
						showmessage(data.msg, function() {
							if (data.success) {
								location.reload(true);
							}
						}, 'account_message');

					}
				});
			});
			//显示消息
			function showmessage(msg, callback, msgId) {
				if (msgId) {
					$('#' + msgId).ucMessage({
						msg : msg,
						callback : callback
					});
				} else {

					$('#message').ucMessage({
						msg : msg,
						callback : callback
					});
				}
			}
		});
	</script>
	<script type="text/javascript"
		src="<c:url value='/static/themes/lightbox2-master/js/lightbox.min.js'/>"></script>
</body>

</html>